package cn.jly.bigdata.spark.streaming

/**
 * @author lanyangji
 * @date 2019/12/5 20:50
 */
object SparkStreaming07_ScalaWindow {

  def main(args: Array[String]): Unit = {

    // Scala的窗口操作
    val ints = List(1, 2, 3,4, 5)

    // 滑动窗口函数，未指定步长默认是1
    //val intses: Iterator[List[Int]] = ints.sliding(2)
    //val intses: Iterator[List[Int]] = ints.sliding(3)
    //val intses: Iterator[List[Int]] = ints.sliding(6)

    // 窗口大小和步长
    val intses: Iterator[List[Int]] = ints.sliding(2, 2)

    for (elem <- intses) {
      println(elem.mkString(","))
    }
  }
}
